define(function() {
	return function($compile, $scope) {
		require(
				[ "AppPathDir/fleet/cteamReserveDoneInfos/support", "AppPathDir/fleet/cteamReserveDoneInfos/reserve", "PDUtilDir/util",
						"PDUtilDir/tool", "PDUtilDir/slidebar",
						"PDUtilDir/inputSelect", "Date", "DateCN", "css!DateCss"],
				function(Support, ReserveSupport, /*UpdateSupport, */Util, Tool, Slidebar, inputSelect) {
                    $scope.cache = {
                        status : new Array(),
                        statuMap : new Map(),
                        type : new Array(),
                        typeMap : new Map(),
                        payStatus : new Array(),
                        payStatuMap: new Map()
                    };
                    $scope.search = {};

					/* 查询 start */
					$scope.searchSupport = {
						run: function(){
							$scope.grid.reload({
                                queryParam : {
                                    model: JSON.stringify($scope.search)
                                }
							})
						}
					};

                    $scope.reserveSupport = ReserveSupport($scope, $compile);

                    //车辆类型
                    $.ajax({
                        url : getServer() + "/flea/hclv/getVehicle.htmls",
                        success : function(data) {
                            $scope.cache.type = data.data;
                            $.each(data.data, function(index, row) {
                            	$scope.cache.typeMap.set(row.dictCode, row.dictName);
                            });
                            init();
                        }
                    });
                    //支付状态列表
                    $.ajax({
                        url : getServer() + "/flea/hclv/getCarReservePayStatus.htmls",
                        success : function(data) {
                            if (data.status != 200) {
                                return;
                            }
                            $scope.cache.payStatus = data.data;
                            $.each(data.data, function(index, row) {
                                $scope.cache.payStatuMap.set(row.dictCode, row.dictName);
                            });
                            init();
                        }
                    });

                    //预定状态
                    $.ajax({
                        url : getServer() + "/flea/hclv/getCarReserveStatus.htmls",
                        success : function(data) {
                            if (data.status != 200) {
                                return;
                            }
                            $scope.cache.status = data.data;
                            $.each(data.data, function(index, row) {
                                $scope.cache.statuMap.set(row.dictCode, row.dictName);
                            });
                            init();
                        }
                    });
					var init = function(){
						if($scope.cache.status.length > 0 && $scope.cache.type.length > 0 && $scope.cache.payStatus.length > 0) {
                            $scope.grid = Support.init($scope.cache, $scope.reserveSupport, $scope.searchSupport);
                        }
					}
				})
	}
});